/*------------------------------------------------------------------------------

Publication: Schakel, W. (2020) Representing the Rich: Economic and Political
	Inequality in Established Democracies. University of Amsterdam: Doctoral
	Dissertation.

Chapter: 2

Description: This do-file runs the analyses presented in the results section of
	chapter 2.
	
Sections:
	
	1. Main analyses
	2. Supplementary appendix 1
	3. Supplementary appendix 2
	4. Supplementary appendix 3
	5. Supplementary appendix 4
	6. Supplementary appendix 5
	7. Additional analyses (not included in supplementary material)

Data: Schakel_2020_Chapter2_1_Data (see Schakel_2020_Chapter2_2_Preparation
	do-file for original sources)

------------------------------------------------------------------------------*/

global data "YOUR PATH HERE"

/*------------------------------------------------------------------------------
 1. Main analyses
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table 1 (random intercept models of changes in welfare state generosity)
mixed dgentav14 all gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table 2 (random intercept models of changes in spending per capita)
mixed dpctav14 all pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed dpctav14 p50 pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed dpctav14 p05 p95 pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed dpctav14 p10 p90 pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed dpctav14 q1 q5 pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed dpctav14 t1 t3 pct loggdpt growtht unempt i.topic i.wave if dgentav14!=. || country:, vce(rob)

* Table 3 (random intercept models of changes in pension generosity)
mixed dgentav14 all gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)

* Table 4 (random intercept models of changes in unemployment generosity)
mixed dgentav14 all gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)

* Table 5 (random intercept models of changes in healthcare generosity)
mixed dgentav14 all gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)

* Table 6 (rich-minus-poor support and change in welfare state generosity)
gen diff0595=p95-p05
gen diff1090=p90-p10
gen diffq1q5=q5-q1
gen difft1t3=t3-t1

foreach var of varlist diff0595 diff1090 diffq1q5 difft1t3 {
	mixed dgentav14 `var' gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
	mixed dgentav14 `var' p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

	foreach t in 2 3 1 {
		mixed dgentav14 `var' gent loggdpt growtht unempt i.wave if topic==`t' || country:, vce(rob)
		mixed dgentav14 `var' p50 gent loggdpt growtht unempt i.wave if topic==`t' || country:, vce(rob)
		}
	}

/*------------------------------------------------------------------------------
 2. Supplementary appendix 1
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table A1.1 (summary statistics)
tabstat all p50 p05 p10 q1 t1 p95 p90 q5 t3 dgentav14 dpctav14 gent pct		///
	gdpt growtht unempt if dgentav14!=. & pct!=., s(mean sd min max n)		///
	col(stat) f(%9.2f)

* Table A1.2 (country-years in ISSP and CWED)
tab country wave if dgentav14!=. & pct!=., s(year) nofreq nostandard

/*------------------------------------------------------------------------------
 3. Supplementary appendix 2
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table A2.2 (changes in replacement rates as alternative dependent variable)
mixed dpgentav14 all pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpgentav14 p50 pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpgentav14 p05 p95 pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpgentav14 p10 p90 pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpgentav14 q1 q5 pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpgentav14 t1 t3 pgent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A2.3 (changes in pension replacement rates as alternative dependent variable)
mixed dpgentav14 all pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dpgentav14 p50 pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dpgentav14 p05 p95 pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dpgentav14 p10 p90 pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dpgentav14 q1 q5 pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dpgentav14 t1 t3 pgent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)

* Table A2.4 (changes in unemployment replacement rates as alternative dependent variable)
mixed dpgentav14 all pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dpgentav14 p50 pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dpgentav14 p05 p95 pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dpgentav14 p10 p90 pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dpgentav14 q1 q5 pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dpgentav14 t1 t3 pgent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)

* Table A2.5 (changes in healthcare replacement rates as alternative dependent variable)
mixed dpgentav14 all pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dpgentav14 p50 pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dpgentav14 p05 p95 pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dpgentav14 p10 p90 pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dpgentav14 q1 q5 pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dpgentav14 t1 t3 pgent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)

* Table A2.6 (changes in per capita spending as dependent variable - maximizing observations)
mixed dpctav14 all pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpctav14 p50 pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpctav14 p05 p95 pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpctav14 p10 p90 pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpctav14 q1 q5 pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dpctav14 t1 t3 pct loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A2.7 (changes in pension spending as dependent variable)
mixed dpctav14 all pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p50 pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p05 p95 pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p10 p90 pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 q1 q5 pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 t1 t3 pct loggdpt growtht unempt i.wave if topic==2 & dgentav14!=. || country:, vce(rob)

* Table A2.8 (changes in unemployment spending as dependent variable)
mixed dpctav14 all pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p50 pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p05 p95 pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p10 p90 pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 q1 q5 pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 t1 t3 pct loggdpt growtht unempt i.wave if topic==3 & dgentav14!=. || country:, vce(rob)

* Table A2.9 (changes in healthcare spending as dependent variable)
mixed dpctav14 all pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p50 pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p05 p95 pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 p10 p90 pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 q1 q5 pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)
mixed dpctav14 t1 t3 pct loggdpt growtht unempt i.wave if topic==1 & dgentav14!=. || country:, vce(rob)

* Table A2.10 (five-year change in welfare state generosity as alternative dependent variable)
mixed dgentav15 all gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav15 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav15 p05 p95 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav15 p10 p90 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav15 q1 q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav15 t1 t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A2.11 (three-year change in welfare state generosity as alternative dependent variable)
mixed dgentav13 all gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav13 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav13 p05 p95 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav13 p10 p90 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav13 q1 q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav13 t1 t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A2.12 (five-year change in per capita spending as alternative dependent variable)
mixed dpctav15 all pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav15 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav15 p05 p95 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav15 p10 p90 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav15 q1 q5 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav15 t1 t3 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)

* Table A2.13 (three-year change in per capita spending as alternative dependent variable)
mixed dpctav13 all pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav13 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav13 p05 p95 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav13 p10 p90 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav13 q1 q5 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav13 t1 t3 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)

/*------------------------------------------------------------------------------
 4. Supplementary appendix 3
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table A3.1 (separate models for low incomes of change in welfare state generosity)
mixed dgentav14 p05 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 q1 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 t1 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A3.2 (separate models for high incomes of change in welfare state generosity)
mixed dgentav14 p95 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p90 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A3.3 (rich-minus-poor support and change in welfare generosity)
gen diff0595=p95-p05
gen diff1090=p90-p10
gen diffq1q5=q5-q1
gen difft1t3=t3-t1

mixed dgentav14 diff0595 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 diff1090 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 diffq1q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 difft1t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A3.4 (rich-minus-poor and median support and change in welfare generosity)
mixed dgentav14 diff0595 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 diff1090 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 diffq1q5 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 difft1t3 p50 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Table A3.5 (rich-minus-poor support and change in pension generosity)
mixed dgentav14 diff0595 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 diff1090 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 diffq1q5 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 difft1t3 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)

* Table A3.6 (rich-minus-poor and median support and change in pension generosity)
mixed dgentav14 diff0595 p50 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 diff1090 p50 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 diffq1q5 p50 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)
mixed dgentav14 difft1t3 p50 gent loggdpt growtht unempt i.wave if topic==2 || country:, vce(rob)

* Table A3.7 (rich-minus-poor support and change in unemployment generosity)
mixed dgentav14 diff0595 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 diff1090 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 diffq1q5 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 difft1t3 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)

* Table A3.8 (rich-minus-poor and median support and change in unemployment generosity)
mixed dgentav14 diff0595 p50 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 diff1090 p50 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 diffq1q5 p50 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)
mixed dgentav14 difft1t3 p50 gent loggdpt growtht unempt i.wave if topic==3 || country:, vce(rob)

* Table A3.9 (rich-minus-poor support and change in healthcare generosity)
mixed dgentav14 diff0595 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 diff1090 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 diffq1q5 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 difft1t3 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)

* Table A3.10 (rich-minus-poor and median support and change in healthcare generosity)
mixed dgentav14 diff0595 p50 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 diff1090 p50 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 diffq1q5 p50 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)
mixed dgentav14 difft1t3 p50 gent loggdpt growtht unempt i.wave if topic==1 || country:, vce(rob)

* Table A3.11 (rich-minus-poor support and change in per capita spending)
mixed dpctav14 diff0595 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 diff1090 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 diffq1q5 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 difft1t3 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)

* Table A3.12 (rich-minus-poor and median support and change in per capita spending)
mixed dpctav14 diff0595 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 diff1090 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 diffq1q5 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)
mixed dpctav14 difft1t3 p50 pct loggdpt growtht unempt i.topic i.wave || country: if dgentav14!=., vce(rob)

* Table A.13 (four-year change in generosity by preferences of rich and poor)
recode p10 p50 p90 (min/0=0) (0/max=1), gen(d10 d50 d90)
recode dgentav14 (min/-0.001=0) (0.001/max=1) (-0.001/0.001=.), gen(ddgen)

table d10 d90 if topic==3 & dgentav14>-20, c(mean ddgen mean dgentav14 n dgentav14)

* Table A.14 (four-year change in generosity by preferences of rich and poor after removing outliers)
table d10 d90 if topic==3 & dgentav14>-20 & dgentav14<7, c(mean ddgen mean dgentav14 n dgentav14)

drop d10 d50 d90 ddgen

/*------------------------------------------------------------------------------
 5. Supplementary appendix 4
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table A4.1 (descriptive statistics of contextual variables)
recode agedem (300/max=300), gen(agedem1)
gen loggall=ln(gallindex)

tabstat agedem1 effpar loggall cabcomp rightgov leftgov fedindex ud			///
	if dgentav14!=. & pct!=., s(mean sd min max n) col(stat) f(%9.2f)

* Table A4.2 (random intercept models of changes in welfare state generosity
* with median preferences and contextual control variables)
mixed dgentav14 p50 gent loggdpt growtht unempt agedem1 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt effpar i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt loggall i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt cabcomp i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt rightgov i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt leftgov i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt fedindex i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt ud i.topic i.wave || country:, vce(rob)

* Table A4.3 (random intercept models of changes in welfare state generosity
* with low and high income preferences and contextual control variables)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt agedem1 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt effpar i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt loggall i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt cabcomp i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt rightgov i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt leftgov i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt fedindex i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt ud i.topic i.wave || country:, vce(rob)

* Table A4.4 (OLS models of changes in welfare state generosity with
* interactions between median preferences and contextual variables)
quietly foreach var of varlist agedem1 effpar loggall cabcomp rightgov leftgov fedindex ud {
	sum `var'
	gen `var'c=`var'-r(mean)
	}

reg dgentav14 c.p50##c.agedem1c gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.effparc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.loggallc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.cabcompc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.rightgovc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.leftgovc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.fedindexc gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p50##c.udc gent loggdpt growtht unempt i.topic i.wave, vce(rob)

* Table A4.5 (OLS models of changes in welfare state generosity with
* interactions between low income preferences and contextual variables)
reg dgentav14 c.p10##c.agedem1c p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.effparc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.loggallc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.cabcompc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.rightgovc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.leftgovc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.fedindexc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)
reg dgentav14 c.p10##c.udc p90 gent loggdpt growtht unempt i.topic i.wave, vce(rob)

* Table A4.6 (controlling for average GDP, economic growth and unemployment between t+1 and t+4
gen loggdptav14=ln((gdpt1+gdpt2+gdpt3+gdpt4)/4)
gen growthtav14=(growtht1+growtht2+growtht3+growtht4)/4
gen unemptav14=(unempt1+unempt2+unempt3+unempt4)/4

mixed dgentav14 all gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p05 p95 gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10 p90 gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 q1 q5 gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 t1 t3 gent loggdptav14 growthtav14 unemptav14 i.topic i.wave || country:, vce(rob)

* Table A4.7 (controlling for average change in GDP, economic growth and unemployment between t+1 and t+4
mixed dgentav14 all gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 p05 p95 gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave|| country:, vce(rob)
mixed dgentav14 p10 p90 gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 q1 q5 gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave || country:, vce(rob)
mixed dgentav14 t1 t3 gent dgdptav14 dgrowthtav14 dunemptav14 i.topic i.wave || country:, vce(rob)

/*------------------------------------------------------------------------------
 6. Supplementary appendix 5
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* Table A5.1 (two-level random intercept, random slope models of change in
* welfare state generosity with country as clusters)
mixed dgentav14 all gent loggdpt growtht unempt i.topic i.wave || country: all, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic i.wave || country: p50, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic i.wave || country: p95, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic i.wave || country: p90, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic i.wave || country: q5, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic i.wave || country: t3, vce(rob)

* Table A5.2 (two-level random intercept models of change in welfare state
* generosity with country-year as clusters)
mixed dgentav14 all gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic || countryyear:, vce(rob)

* Table A5.3 (two-level random intercept models of change in welfare state
* generosity with country-topic as clusters)
mixed dgentav14 all gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic i.wave || countrytopic:, vce(rob)

* Table A5.4 (three-level random intercept models of change in welfare state
* generosity with country and wave as clusters)
mixed dgentav14 all gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic || country: || wave:, vce(rob)

* Table A5.5 (three-level random intercept models of change in welfare state
* generosity with country-year as third level)
mixed dgentav14 all gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)
mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)
mixed dgentav14 p05 p95 gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)
mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)
mixed dgentav14 t1 t3 gent loggdpt growtht unempt i.topic || country: || countryyear:, vce(rob)

* Table A5.6 (jackknife analysis by country)
recode country (1=1) (2=2) (4=3) (7=4) (8=5) (9=6) (10=7) (11=8) (13=9)		///
	(15=10) (16=11) (18=12) (19=13) (20=14) (22=15) (24=16) (25=17) (26=18)	///
	(27=19) (29=20) (else=.), gen(ctemp)

matrix jk1=J(20,6,.)
matrix colnames jk1=Coeff(P10) SE(P10) p(P10) Coeff(P90) SE(P90) p(P90)
matrix rownames jk1=AU AT CA DK FI FR DE GB IE IT JP NL NZ NO PT SK ES SE CH US

quietly forval x=1/20 {
	mixed dgentav14 p10 p90 gent loggdpt growtht unempt i.topic i.wave if ctemp!=`x' || country:, vce(rob)
	matrix rtable=r(table)
	matrix jk1[`x',1]=rtable[1,1]
	matrix jk1[`x',2]=rtable[2,1]
	matrix jk1[`x',3]=rtable[4,1]
	matrix jk1[`x',4]=rtable[1,2]
	matrix jk1[`x',5]=rtable[2,2]
	matrix jk1[`x',6]=rtable[4,2]	
	}

matrix list jk1, format(%9.3f)

matrix jk2=J(20,6,.)
matrix colnames jk2=Coeff(Q1) SE(Q1) p(Q1) Coeff(Q5) SE(Q1) p(Q5)
matrix rownames jk2=AU AT CA DK FI FR DE GB IE IT JP NL NZ NO PT SK ES SE CH US

quietly forval x=1/20 {
	mixed dgentav14 q1 q5 gent loggdpt growtht unempt i.topic i.wave if ctemp!=`x' || country:, vce(rob)
	matrix rtable=r(table)
	matrix jk2[`x',1]=rtable[1,1]
	matrix jk2[`x',2]=rtable[2,1]
	matrix jk2[`x',3]=rtable[4,1]
	matrix jk2[`x',4]=rtable[1,2]
	matrix jk2[`x',5]=rtable[2,2]
	matrix jk2[`x',6]=rtable[4,2]	
	}

matrix list jk2, format(%9.3f)

/*------------------------------------------------------------------------------
 7. Additional analyses (not included in supplementary material)
------------------------------------------------------------------------------*/

use "$data\Schakel_2020_Chapter2_1_Data.dta", clear

* OLS models with jackknife standard errors (country clustering)
reg dgentav14 all gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))
reg dgentav14 p50 gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))
reg dgentav14 p10 p90 gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))
reg dgentav14 p05 p95 gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))
reg dgentav14 q1 q5 gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))
reg dgentav14 t1 t3 gent loggdpt growtht unempt i.topic i.wave, vce(jackknife, cluster(country))

* Reverse causality models (see footnotes of chapter 2)
mixed all dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=.|| country:, vce(rob)
mixed p50 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed p05 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed p95 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed p10 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed p90 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed q1 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed q5 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed t1 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)
mixed t3 dpctminus14 pctminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave if dgentav14!=. || country:, vce(rob)

mixed all dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed p50 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed p05 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed p95 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed p10 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed p90 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed q1 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed q5 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed t1 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)
mixed t3 dgentminus14 gentminus5 loggdptminus5 growthtminus5 unemptminus5 i.topic i.wave || country:, vce(rob)

* Centering independent variables (see footnotes of chapter 2)
gen p10c=p10-all
gen p50c=p50-all
gen p90c=p90-all

mixed dgentav14 p50c gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10c p90c gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p90c gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p10c gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Middle and high incomes simultaneously (see footnotes of chapter 2)
mixed dgentav14 p50 p95 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 p50 p90 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 q3 q5 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)
mixed dgentav14 t2 t3 gent loggdpt growtht unempt i.topic i.wave || country:, vce(rob)

* Additional controls (see footnotes of chapter 2)
mixed dgentav14 all gent loggdpt growtht unempt i.topic i.wave wsvall bcpall || country:, vce(rob)
mixed dgentav14 p50 gent loggdpt growtht unempt i.topic i.wave wsv50 bcp50 || country:, vce(rob)
mixed dgentav14 p95 gent loggdpt growtht unempt i.topic i.wave wsv95 bcp95 || country:, vce(rob)
mixed dgentav14 p90 gent loggdpt growtht unempt i.topic i.wave wsv90 bcp90 || country:, vce(rob)
